package com.paper.tiger.easy.rpc.center;

import com.paper.tiger.easy.rpc.core.GeneralHandleData;
import com.paper.tiger.easy.rpc.core.RegisterServerMesage;
import com.paper.tiger.easy.rpc.core.ServerType;

import java.util.List;

/**
 * [简要描述]:
 * [详细描述]:
 *
 * @author ZouHaiBo
 * @version 1.0, 2021/5/31 09:15
 * @since JDK 1.8
 */
public class RegisterService implements BasicService
{

    @Override
    public GeneralHandleData service(GeneralHandleData generalHandleData)
    {
        System.out.println("-----------------接收到注册请求---------------");

        List<RegisterServerMesage> list = generalHandleData.getList();

        for (RegisterServerMesage message : list)
        {
            ServerMap.registerServer(message.getInterfaceClass(),message);
        }
        GeneralHandleData data = new GeneralHandleData();
        data.setResult(Boolean.TRUE);
        data.setType(ServerType.REGISTER_RESPONSE.getCode());

        return data;
    }
}
